﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using E4D.AppFabric.Entities.Properties;

namespace MDCAdminTool
{
    public class PowerShellCommand
    {
        public string CommandName { get; set; }
        public Dictionary<string , object> Parameters { get; set; }
        public string Command
        {
            get
            {
                var sb = new StringBuilder();
                sb.AppendFormat( "{0} " , CommandName );

                if ( Parameters != null )
                {
                    foreach ( var c in Parameters )
                    {
                        sb.AppendFormat( " -{0}  {1} " , c.Key , c.Value );
                    }
                }
                return sb.ToString();
            }
            
        }
        public string Tooltip
        {
            get
            {
                string tip = string.Empty;
                try
                {
                    var values = CommandName.Split('-');
                    string cn  = string.Format("{0}{1}", values[0], values[1]);
                    tip = CommandTooltip.ResourceManager.GetString( cn , CommandTooltip.Culture );
                }
                catch {}

                return tip;
            }
        }
        public bool IsError
        {
            get
            {
                return Command.Contains("ErrorCode");
            }
        }

        public override string ToString()
        {
            return Command;
        }
    }
}
